﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Lab2
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        PhanSo p = new PhanSo();
        Support s = new Support();
        ChangeUnits c = new ChangeUnits();
        [WebMethod]
        public PhanSo Add(int tu1, int mau1, int tu2, int mau2)
        {
            PhanSo p1 = new PhanSo(tu1, mau1);
            PhanSo p2 = new PhanSo(tu2, mau2);

            return p.Operation(p1, p2, PhanSo.Operator.Addition);
        }

        [WebMethod]
        public PhanSo Sub(int tu1, int mau1, int tu2, int mau2)
        {
            PhanSo p1 = new PhanSo(tu1, mau1);
            PhanSo p2 = new PhanSo(tu2, mau2);

            return p.Operation(p1, p2, PhanSo.Operator.Subtraction);
        }

        [WebMethod]
        public PhanSo Multi(int tu1, int mau1, int tu2, int mau2)
        {
            PhanSo p1 = new PhanSo(tu1, mau1);
            PhanSo p2 = new PhanSo(tu2, mau2);

            return p.Operation(p1, p2, PhanSo.Operator.Multiplication);
        }

        [WebMethod]
        public PhanSo Div(int tu1, int mau1, int tu2, int mau2)
        {
            PhanSo p1 = new PhanSo(tu1, mau1);
            PhanSo p2 = new PhanSo(tu2, mau2);

            return p.Operation(p1, p2, PhanSo.Operator.Division);
        }

        [WebMethod]
        public List<PhanSo> CreateList(int n)
        {
            return p.CreateList(n);
        }

        [WebMethod]
        public long Factorial(int n)
        {
            return s.GiaiThua(n);
        }

        [WebMethod]
        public List<int> ListNT(int n)
        {
            return s.CreateNT(n);
        }

        [WebMethod(MessageName = "1=USD2VND, 2=VND2USD, 3=EUR2VND ,4 VND2EUR, 5=YP2VND ,6=VND2YP")]
        public decimal ChangeUnit(decimal money, ChangeUnits.TypeChange type)
        {
            return c.Change(money, type);
        }
    }
}